Set Connection (QxdaSetConnection) API


  Required Parameter Group:


  Service Program: QXDAEDRS

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes

A transaction manager calls QxdaSetConnection() to perform XA-transaction related operations for a particular connection.


Authorities and Locks

None.


Required Parameter Group

Connection handle
INPUT; BINARY(4)

The handle number of the connection on which to perform the XA operation. The connection handle must have been generated by the QxdaConnectEDRS API in the current job and activation group.

Transaction branch identifier
INPUT; CHAR(*)

The transaction branch identifier. This identifier is generated by the transaction manager when it starts the transaction branch. The max length is 140 bytes.




Return value
OUTPUT; BINARY(4)

The return value of the XA operation. Possible return values:


Operation
INPUT; BINARY(4)

Valid operations are:


Note:QXDA_SQL_TXN_JOIN, QXDA_SQL_TXN_CREATE, QXDA_SQL_TXN_LOOSELY_COUPLED_CREATE, and QXDA_SQL_TXN_RESUME are similar to a xa_start; whereas, QXDA_SQL_TXN_SUSPEND, QXDA_SQL_TXN_END, and QXDA_SQL_TXN_END_FAIL are similar to a xa_end.

Note:QXDA_SQL_TXN_FIND has the same result as a QXDA_SQL_TXN_JOIN.

Timeout value
INPUT; BINARY(4)

Timeout value for the transaction in seconds. If the Timout Value is not greater than 0, then the default system timeout value will be used. This value must be >= 0 and applies to the QXDA_SQL_TXN_CREATE and QXDA_SQL_TXN_LOOSELY_COUPLED_CREATE operations.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.



Usage Notes

This function may be called from the initial thread of a job only.


Error Messages


Related Information

The QxdaXA APIs follow the NTS (transactions with transaction scoped locks) model. For more information regarding the NTS model, see XA APIs.

Example

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include qxdaedrs.h 

main()
{ 
err_t     err; 
Qxda_CDBI0100_t *istr = (Qxda_CDBI0100_t *)instruct;
Qxda_CDBO0100_t  ostr;
int ostrsize;
XID inxid;
char gtrid[8] = "TestXA";
char bqual[6] = "Test"; 
inxid.formatID = 0;  
inxid.gtrid_length = 6; 
inxid.bqual_length = 4; 
int create = QXDA_SQL_TXN_CREATE;
int timeoutval = 60;
int ret_val; 
_CPYBYTES(dtaara, gtrid, inxid.gtrid_length); 
_CPYBYTES(dtaara + inxid.gtrid_length, bqual, inxid.bqual_length);   
_CPYBYTES(inxid.data, dtaara, inxid.gtrid_length + inxid.bqual_length); 
XID *xid = &inxid;





 memset(istr, '\0', sizeof(Qxda_CDBI0100_t));                  

 istr->Connection_Type = 'U';                                                        
 memset(istr->Server_Name, ' ', 256);                  
 istr->Commitment_Control = 'S';                          
 _CPYBYTES(istr->Commit_Scope, "*XA                      ", 10);         
 istr->Allow_Suspend = 'Y';
 memset(istr->RDB_Specified, '0', 1);
 istr->SQLDA_Cache_Size = 10;                             
 istr->Offset_Job_Data = sizeof(Qxda_CDBI0100_t);         
 istr->Length_Job_Data = 7;                               
 _CPYBYTES((char *)istr + istr->Offset_Job_Data, "CONNECT", 7);   
 istr->Offset_Suspend_Data = istr->Offset_Job_Data + istr->Length_Job_Data; 
 istr->Length_Suspend_Data = 7;   
 memset(istr->RDB_Name, ' ', 18);
 _CPYBYTES(istr->TM_Info, "TM_Name         ", 10); 
 istr->LockTimeoutVal = 10;  
 ostrsize = sizeof(Qxda_CDBO0100_t);                                        


 QxdaConnectEDRS(istr, "CDBI0100", &ostr, &ostrsize,
                  "CDBO0100", &err);


 QxdaSetConnection(&ostr.Connection_Handle,  xid, &ret_val, &create, &timeoutval, &err);
} 


API introduced: V5R3

[ Back to top | Database and File APIs | APIs by category ]